<html>
  <head>
  <title>Sciter Help</title>
  <style>
    @import url(styles/main.css);
  </style>
  <script type="text/tiscript">
    const APP_NAME = "sciter-help";
    include "toc.tis";
    include "indexer.tis";
    include "settings.tis";
    var back      = self.$(toolbar>button.back);
    var forward   = self.$(toolbar>button.forward);
    var frameset  = self.$(frameset#body);
    var contentFrame = self.$(frame#content);
    var toc = self.$(#toc);
    back.onClick    = :: frameset.goBack();  
    forward.onClick = :: frameset.goForward();  

    function generateToc()
    {
      var cbody = contentFrame[0].$(body);
      if( cbody ) makeToc(cbody,toc);
      else toc.clear();
    }
   
    event historyStateChange 
    {
      back.state.disabled = !frameset.canGoBack();
      forward.state.disabled = !frameset.canGoForward();
      generateToc();
    }

    contentFrame << event complete
    {
		  generateToc();
		  if(afterTocEvent) {
			  afterTocEvent();
		    afterTocEvent = null;
      }
	  }

    contentFrame << event ~click $(a[href^="http"]) (evt)
    {
      Sciter.launch(evt.target.@["href"]); // show external URLs in system browser.
      return true;
    }
    
  	var afterTocEvent;
  	function GoToPage(pageurl, toc_entry)
  	{
  		if(contentFrame[0].url().indexOf(pageurl)!=-1)
  		{
  			goTocSection(toc_entry);
  		} else {
  			contentFrame.load(pageurl);
  			
  			afterTocEvent = function() {
  				goTocSection(toc_entry);
  			};
  		}
  	}
  	
  	View.SciterDocsGoToPage = GoToPage;

  // persistence of frameset state
  Settings.add {
    store: function(data) 
      {
        data.frameset =  frameset.framesetState();  
      },
    restore: function(data) 
      {
        if( data.frameset )
          frameset.framesetState(data.frameset);
      }
  }; 

  function statechange { saveState(); /* settings.tis */ } 

  Settings.restore();

  </script>
  </head>
  <body>
  <toolbar>
    <button accesskey="LEFT" .back disabled title="Go backward" />
    <button accesskey="RIGHT" .forward disabled title="Go forward" />
  </toolbar>
  <frameset #body history>
    <div #index >
      <include src="help-index.htm">
        help-index.htm not found!  
      </include>
    </div>
    <splitter/>
    <frame #content src="" src="content/preface.htm" content-style="styles/content.css"/>
    <splitter/>    
    <div #toc />
  </frameset>
  </body>
</html>
